﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace Palsta.Core
{
    public class DataParser
    {
        #region Members
        /*
         * Inner Members
         */
        protected XmlDocument _xmlDoc = new XmlDocument(); // Xml document Object
        #endregion

        /*
         * Load data definitions into data dictionary
         */ 
        public void Load(String path)
        {
            _xmlDoc.Load(path);
            XmlNodeList elements = _xmlDoc.GetElementsByTagName("xsd:element");
            foreach (XmlNode element in elements)
            {
                if (element.ChildNodes.Count > 0) continue;
                DataInfo dataDefintion = DataInfoFactory.CreateInstance(element);
                if (dataDefintion == null) continue;
                DataDictionary.Instance().Add(dataDefintion.Name, dataDefintion);
            }
        }
    }
}
